package com.yand.serviceimpl.business.business;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yand.api.entity.business.product.THfDiscountDetail;
import com.yand.api.service.business.DiscountService;
import com.yand.mapper.business.product.THfDiscountDetailMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;


/**
 * 折扣明细业务接口实现类
 */
@Service
public class DiscountServiceImpl implements DiscountService {

    @Autowired
    private THfDiscountDetailMapper discountDetailMapper;


    /**
     * 查询所有的折扣明细信息
     * @param discountDetail
     * @return
     */
    @Override
    public PageInfo<THfDiscountDetail> queryAllDiscountList(THfDiscountDetail discountDetail) {
        PageHelper.startPage(discountDetail.getPageNum(), discountDetail.getPageSize());

        return PageInfo.of(discountDetailMapper.selectAllDiscountList(discountDetail));
    }


    /**
     * 根据充值金额获取折扣信息
     * @param payMoney
     * @return
     */
    @Override
    public THfDiscountDetail queryDiscountByPayMoney(String payMoney) {
        THfDiscountDetail discountDetail = new THfDiscountDetail();
        discountDetail.setPayMoney(new BigDecimal(payMoney));
        return discountDetailMapper.selectDiscountBean(discountDetail);
    }
}
